package com.huawei.bus.minitest;

import java.io.File;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.huawei.bus.minitest.conf.Conf;
import com.huawei.bus.minitest.util.FileUtils;

public class Bootstrap {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(Bootstrap.class.getResource("/"));
		try {
			init();
		} catch (JSONException e) {
			e.printStackTrace();
			System.exit(0);
		}
		runTest();
	}

	private static void runTest() {
		TestSuite ts = new TestSuite();
		ts.loadTestSuites();
		ts.runAll();
	}

	private static void init() throws JSONException {
		Conf.init();
	}

	private static void testJson() {
		String filepath = "E:"+File.separator+"workspaces"+File.separator+"itest"+File.separator+"suitecase"+File.separator+"demo"+File.separator+"test1.json";
		String str = FileUtils.readFileByChars(filepath);
		
		try {
			JSONObject json = new JSONObject(str);
			String name = (String) json.get("name");
			JSONArray jsArr = json.getJSONArray("steps");
			if(jsArr != null && jsArr.length()>0)
			{
				for(int i = 0; i < jsArr.length();i++){
					JSONObject currJsObj = jsArr.getJSONObject(i);
					String type = (String)currJsObj.get("type");
					System.out.println();
					System.out.println(type);
				}
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
